<!--
 * @Author: your name
 * @Date: 2021-05-20 16:07:51
 * @LastEditTime: 2021-05-28 17:19:32
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \wallet\src\views\kstoPayCard.vue
-->
<template>
  <div class="main_body1">
    <div class="main" style="margin-top:200px;">
      <!-- <div class="" style="font-size:120px;color:#49ccc3;" >+</div> -->
      <van-icon name="add-o" size="120" color="#49ccc3" @click="addPay()" />
    </div>
    <div class="main">
      <div style="font-size:24px;color:#49ccc3;">添加支付宝/银行卡</div>
    </div>
  </div>
</template>
<script>
  var baseConfig = require("../utils/baseConfig");

  import Vue from 'vue';
  import { Icon, Dialog } from 'vant';

  Vue.use(Icon);
  Vue.use(Dialog);

  export default {
    name: 'kstoPayCard',
    data() {
      return {
        date: '',
      };
    },
    created() {
      this.get_bank_alipay_list(); // 暂时注释
    },
    methods: {
      addPay(){
        // console.log('111');
        this.$router.push('/ksaddPay');
      },
      get_bank_alipay_list() {
        // let loginUserId = 'ohI6C4tTiL0skHDt-FaRfOnBMkI0';
        let loginUserId = JSON.parse(localStorage.getItem('userInfo')).openid;
        let uid = JSON.parse(localStorage.getItem('userInfo')).id;
        this.$http.post(`${baseConfig.url}tuiwaApp/get_bank_alipay_list?loginUserId=` + loginUserId
          + '&uid=' + uid)
          .then(
            res => {
              console.log(res.data.data[0]);
              if (res.data.code == 200) {
                if (res.data.data[0].status == 0){
                  // console.log('00000000');
                  Dialog.confirm({
                    title: '提示',
                    message: '正在审核，请耐心等候',
                    confirmButtonText: '查看进度',
                  })
                    .then(() => {
                      this.$router.push('/ksmyPayCard');
                    })
                    .catch(() => {
                      this.$router.go(-1);
                    });
                } else if (res.data.data[0].status == 2){
                  console.log('222222222');
                  Dialog.confirm({
                    title: '提示',
                    message: '添加支付方式失败',
                    confirmButtonText: '重新添加',
                  })
                    .then(() => {
                      this.$router.push('/ksaddPay');
                    })
                    .catch(() => {
                      this.$router.go(-1);
                    });
                } else {
                  console.log('111111111');
                  Dialog.confirm({
                    title: '提示',
                    message: '审核已通过',
                    confirmButtonText: '查看',
                  })
                    .then(() => {
                      this.$router.push('/ksmyPayCard');
                    })
                    .catch(() => {
                      this.$router.go(-1);
                    });
                }
                  // console.log(this.tixian);
                  // this.bankName = res.data.data[0].bankName
                  // this.bankCardNum = res.data.data[0].bankCardNum.replace(/\s/g, '').replace(/(\d{4})\d+(\d{4})$/, "**** **** **** $2") // 将银行卡号前部分用 * 代替，仅显示后四位
                  // this.aliPayAccount = res.data.data[0].aliPayAccount
                  // this.trueName = res.data.data[0].trueName
                  // this.status = res.data.data[0].status
                  // this.accountType= res.data.data[0].accountType
              } else {
                  return false;
              }
            }
          )
          .catch(
            err => {
              console.log(err);
            }
          )
      },
      
    },
  }
</script>
<style scoped>
.main {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 200px;
}
</style>
